//
//  HEAIMsgTextCell.m
//  HealthFamily
//
//  Created by 吴欧 on 2020/11/22.
//  Copyright © 2020 honglutec. All rights reserved.
//

#import "HEAIMsgTextCell.h"

@interface HEAIMsgTextCell ()

@property (nonatomic, strong) UIImageView *headImageView;
@property (nonatomic, strong) UILabel *titleLb;

@end

@implementation HEAIMsgTextCell

- (instancetype)initWithStyle:(UITableViewCellStyle)style reuseIdentifier:(NSString *)reuseIdentifier {
    
    if (self = [super initWithStyle:style reuseIdentifier:reuseIdentifier]) {
        self.selectionStyle = UITableViewCellSelectionStyleNone;
        self.backgroundColor = CViewBgColor;
        [self initUI];
    }
    return self;
}

- (void)initUI {
    
    // 头像
    _headImageView = [UIImageView new];
    _headImageView.image = IMAGE_NAMED(@"home_ai");
    _headImageView.contentMode = UIViewContentModeScaleAspectFill;
    [self.contentView addSubview:_headImageView];
    
    UIView *warp = [UIView new];
    warp.backgroundColor = KWhiteColor;
    [self.contentView addSubview:warp];
    
    warp.layer.shadowColor = [UIColor colorWithRed:13/255.0 green:98/255.0 blue:218/255.0 alpha:0.08].CGColor;
    warp.layer.shadowOffset = CGSizeMake(0,5);
    warp.layer.shadowOpacity = 1;
    warp.layer.shadowRadius = 6;
    warp.layer.cornerRadius = 10;
    
    _titleLb = [UILabel new];
    _titleLb.text = @"";
    _titleLb.font = DYFont(16);
    _titleLb.textColor = CNavLightBlackColor;
    _titleLb.numberOfLines = 0;
    [warp addSubview:_titleLb];

    
    [_headImageView mas_makeConstraints:^(MASConstraintMaker *make) {
       make.top.equalTo(self.contentView).mas_offset(10);
       make.left.equalTo(self.contentView).mas_offset(15);
       make.width.height.mas_offset(50);
    }];
    [_headImageView hg_setAllCornerWithCornerRadius: 25];
    
    
    [warp mas_makeConstraints:^(MASConstraintMaker *make) {
        make.top.equalTo(_headImageView.mas_top);
        make.left.equalTo(_headImageView.mas_right).mas_offset(15);
        make.bottom.equalTo(self.contentView).mas_offset(-10);
    }];
     
    [_titleLb mas_makeConstraints:^(MASConstraintMaker *make) {
        make.top.equalTo(warp).mas_offset(15);
        make.left.equalTo(warp).mas_offset(15);
        make.right.equalTo(warp).mas_offset(-15);
        make.bottom.equalTo(warp).mas_offset(-15);
    }];
    [_titleLb setContentHuggingPriority:UILayoutPriorityRequired forAxis:UILayoutConstraintAxisHorizontal];
}

- (void)refreshContent:(GDFiterCellModel *)fiterModel formModel:(GDFormModel *)formModel indexPath:(NSIndexPath *)indexPath {
    
    
    _titleLb.text = formModel.zx_model.content;
    [_titleLb mas_updateConstraints:^(MASConstraintMaker *make) {
        make.width.mas_offset(formModel.zx_model.contentWidth);
    }];
}

- (void)setSelected:(BOOL)selected animated:(BOOL)animated {
    [super setSelected:selected animated:animated];

    // Configure the view for the selected state
}

@end
